From: Jasper St. Pierre Date: Sat, 1 Dec 2012 01:35:04 +0000 (-0500) Subject: iconGrid: Only recreate icons when needed X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~5234 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=429f9e1d15b416f83ab7d4cf82ae1e1d7ce32925;p=gnome-shell.git iconGrid: Only recreate icons when needed Recreating icons on every style change -- like hover, can have disasterous effects. Not only is the quick creation/destruction of the actors bad, but adding/removing actors at runtime queues many relayouts, which makes the whole system slower as a lot of unnecessary reallocations are figured out. While an optimization was here before, it was broken because it broke high-contrast themes. Connect explicitly to the texture cache to know when the icon theme has changed, instead of removing a valuable optimization. https://bugzilla.gnome.org/show_bug.cgi?id=672941 --- diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js index 04b8caf69..2b6386531 100644 --- a/js/ui/iconGrid.js +++ b/js/ui/iconGrid.js @@ -23,6 +23,8 @@ const BaseIcon = new Lang.Class({ this.actor._delegate = this; this.actor.connect('style-changed', Lang.bind(this, this._onStyleChanged)); + this.actor.connect('destroy', + Lang.bind(this, this._onDestroy)); this._spacing = 0; @@ -52,6 +54,9 @@ const BaseIcon = new Lang.Class({ this._setSizeManually = params.setSizeManually; this.icon = null; + + let cache = St.TextureCache.get_default(); + this._iconThemeChangedId = cache.connect('icon-theme-changed', Lang.bind(this, this._onIconThemeChanged)); }, _allocate: function(actor, box, flags) { @@ -146,7 +151,22 @@ const BaseIcon = new Lang.Class({ size = found ? len : ICON_SIZE; } + if (this.iconSize == size && this._iconBin.child) + return; + this._createIconTexture(size); + }, + + _onDestroy: function() { + if (this._iconThemeChangedId > 0) { + let cache = St.TextureCache.get_default(); + cache.disconnect(this._iconThemeChangedId); + this._iconThemeChangedId = 0; + } + }, + + _onIconThemeChanged: function() { + this._createIconTexture(this.iconSize); } });